package com.fas.system.service.impl;

import com.fas.common.core.redis.RedisCache;
import com.fas.system.domain.FasFireHydrant;
import com.fas.system.mapper.FasFireHydrantMapper;
import com.fas.system.service.IFasFireHydrantService;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import javax.annotation.Resource;
import java.util.List;

@Service
public class FasFireHydrantServiceImpl implements IFasFireHydrantService {

    @Resource
    private FasFireHydrantMapper fasFireHydrantMapper;
    @Resource
    private RedisCache redisCache;

    @Override
    public List<FasFireHydrant> findAllEquipment(FasFireHydrant fasFireHydrant) {
        List<FasFireHydrant> list = fasFireHydrantMapper.findAllEquipment(fasFireHydrant);
        list.forEach(ll -> ll.setCompanyName(FasCooperationCompanyServiceImpl.COMPANY_NAMES.get(ll.getCooperationCompanyId())));
        return list;
    }

    @Override
    public List<FasFireHydrant> findLikeEngineer(FasFireHydrant fasFireHydrant) {
        List<FasFireHydrant> list = fasFireHydrantMapper.findLikeEngineer(fasFireHydrant);
        list.forEach(ll -> ll.setCompanyName(FasCooperationCompanyServiceImpl.COMPANY_NAMES.get(ll.getCooperationCompanyId())));
        return list;
    }

    @Override
    @Transactional(rollbackFor = Exception.class)
    public int insertFasFireHydrant(FasFireHydrant fasFireHydrant) {
        return fasFireHydrantMapper.insertFasFireHydrant(fasFireHydrant);
    }

    @Override
    @Transactional(rollbackFor = Exception.class)
    public int updateFasFireHydrant(FasFireHydrant fasFireHydrant) {
        return fasFireHydrantMapper.updateFasFireHydrant(fasFireHydrant);
    }

    @Override
    @Transactional(rollbackFor = Exception.class)
    public int deleteFasFireHydrant(Integer id) {
        return fasFireHydrantMapper.deleteFasFireHydrant(id);
    }
}
